package com.sweetguy.entity;

import com.mybatisflex.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 *  实体类。
 *
 * @author SweetGuy
 * @since 2024-12-22
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(value = "course", schema = "ml_cms")
public class Course implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键，自增
     */
    @Id(keyType = KeyType.Auto)
    private Long id;

    /**
     * 课程标题，非空
     */
    private String title;

    /**
     * 作者，非空
     */
    private String author;

    /**
     * 分类ID，课程类别表外键
     */
    private Long fkCategoryId;

    /**
     * 摘要图地址
     */
    private String summary;

    /**
     * 封面图片链接
     */
    private String cover;

    /**
     * 课程价格，包含8位整数和2位小数
     */
    private Double price;

    /**
     * 序号
     */
    private Long idx;

    /**
     * 描述
     */
    private String info;

    /**
     * 数据版本，非空，默认值为0
     */
    @Column(version = true)
    private Long version;

    /**
     * 逻辑删除标记，非空，默认值为0表示未删除，1表示已删除
     */
    @Column(isLogicDelete = true)
    private Integer deleted;

    /**
     * 创建时间，非空，默认为当前时间
     */
    private LocalDateTime created;

    /**
     * 更新时间，非空，默认为当前时间，记录更新时自动修改
     */
    private LocalDateTime updated;

    //课程[n] : 类别[1]
    @RelationManyToOne(selfField = "fkCategoryId", targetField = "id")
    private Category category;

    //课程[1] : 季次[n]
    @RelationOneToMany(selfField = "id", targetField = "fkCourseId")
    private List<Season> seasons;
}
